<!doctype html>
<html>

	<head>
		<meta charset="UTF-8" />
		<title>实名认证</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css" />
		<link rel="stylesheet" href="../css/reg.css" />
		<script src="../js/mui.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" href="../css/common.css" />
		<script type="text/javascript">
			mui.init();
			if (location.pathname != "/h5/html/login.html" && typeof(sessionStorage.token) == "undefined") {

				mui.openWindow({
					url: 'login.html',

				});
			}
		</script>
		<script type="text/javascript" src="../js/common.js"></script>
	</head>

	<body>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>登录账户</label>
					<label style="padding-left: 0;" class="reg_name"></label>
				</div>

				<div class="mui-input-row">
					<label>姓名</label>
					<input type="text" class="mui-input-clear identifyName" placeholder="请输入真实姓名">
				</div>

				<!--<div class="mui-input-row">
					<label>证件类型</label>
					<select>
							  <option value="none">请选择证件类型</option>
							  <option value="sfz">身份证</option>
			  </select>
					<img src="../images/bottom.png" style="position: absolute;right: 1rem;top: 0.1rem;width: 24px;height: 24px;" />
				</div>-->
				<div class="mui-input-row">
					<label>身份证号</label>
					<input type="text" class="mui-input-clear identifyNumber" placeholder="请输入身份证号">
				</div>
				<div class="mui-input-row">
					<label>手机号码</label>
					<input type="text" class="mui-input-clear reg_phone" placeholder="请输入手机号码">
				</div>
				<div class="mui-input-row">
					<label>短信验证</label>
					<input type="text" class="" placeholder="请输入验证码" id="input_phone_message">
					<button type="button" class="mui-btn mui-btn-blue smsVerifyCode" id="btn_phone_message">获取验证码</button>
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='reg' class="mui-btn mui-btn-block mui-btn-primary">确认</button>
			</div>
		</div>

	</body>

</html>
<script>
	document.querySelector(".reg_name").innerHTML = sessionStorage.userName;
	var smsVerifyCode = document.querySelector(".smsVerifyCode");
	smsVerifyCode.addEventListener("tap", function() {
		var reg_phone = document.querySelector(".reg_phone").value;
		var reg1 = /(^1[3|4|5|7|8][0-9]{9}$)/;
		if (reg1.test(reg_phone) == false) {
			mui.toast("请输入正确的手机号码")
			return
		}
		smsVerifyCode.disabled = true;
		var next_time = 60;
		var time_out = setInterval(function() {
			if (next_time == 0) {
				smsVerifyCode.disabled = false;
				smsVerifyCode.innerHTML = "获取验证码";
				clearInterval(time_out);
			} else {
				next_time = next_time - 1;
				smsVerifyCode.innerHTML = next_time;
			}
		}, 1000)
		mui.ajax("/api/v1/sms/send/code", {
			data: {
				paramStr: "{mobile:" + reg_phone + ",ip:127.0.0.1,type:securitySetting}"
			},
			dataType: 'json',
			type: 'post',
			success: function(data) {
	
				mui.toast(data.message);
			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				console.log(type);
			}
		});
		
	});
	document.querySelector("#reg").addEventListener("tap", function() {
		var identifyNumber=document.querySelector(".identifyNumber").value;
		var identifyName=document.querySelector(".identifyName").value;
		var smsVerifyCode=document.getElementById("input_phone_message").value;
		mui.ajax("/api/v1/authIdentify", {
			data: {
				paramStr: "{'userName':'" + sessionStorage.userName + "','smsVerifyCode':'"+smsVerifyCode + "','token':'"+sessionStorage.token+"','identifyName':'"+identifyName+"','identifyNumber':'"+identifyNumber+"'}"
			},
			dataType: 'json',
			type: 'post',
			success: function(data) {
				
				mui.toast(data.message);
				if(data.code==200){
					sessionStorage.isVerify=true;
					setTimeout(function() {
						mui.openWindow({
							url: '../index.html',
						});
					}, 3000)

				}
				
			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				console.log(type);
			}
		});

	})
</script>